package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Administrator
 * Date: 2023-04-08
 * Time: 15:42
 */
class Solution {
    public ListNode removeElements(ListNode head, int val) {
        while (head != null && head.val == val) {
            head = head.next;
        }
        if(head == null){
            return null;
        }
        ListNode ure = head;
        while(ure.next != null){
            if(ure.next.val == val){
                ure.next = ure.next.next;
            }else{
                ure = ure.next;
            }
        }
        return head;
    }
}
public class Test1 {
}
